package br.uece.laconi.tac.ga.util;

import java.util.Comparator;

import jmetal.base.Solution;
	 
public class GA4TACComparator implements Comparator<Solution> {

	public int compare(Solution o1, Solution o2) {
		int retorno = 0;
		if(o1 == null || o2 == null)
			throw new ClassCastException("null");
		
		//prioridade para GANHO-INVENTARIO-DESP.OP
		if ((Math.abs(o1.getObjective(0)) - Math.abs(o1.getObjective(1)) - Math
				.abs(o1.getObjective(2))) < (Math.abs(o2.getObjective(0))
				- Math.abs(o2.getObjective(1)) - Math.abs(o2.getObjective(2))))
			retorno = -(int) (Math.abs(o1.getObjective(0)) + Math.abs(o1.getObjective(1)) + Math
					.abs(o1.getObjective(2))) ;

		else retorno = (int) (Math.abs(o2.getObjective(0))
				- Math.abs(o2.getObjective(1)) - Math.abs(o2.getObjective(2)));

		
// prioridade para as solucoes que retornam maior valor para GANHO+INVENTARIO-DESP.OPERACIONAL
//		if ((Math.abs(o1.getObjective(0)) - Math.abs(o1.getObjective(1)) + Math
//				.abs(o1.getObjective(2))) < (Math.abs(o2.getObjective(0))
//				- Math.abs(o2.getObjective(1)) + Math.abs(o2.getObjective(2))))
//			retorno = -(int) (Math.abs(o1.getObjective(0)) + Math.abs(o1.getObjective(1)) - Math
//					.abs(o1.getObjective(2))) ;
//
//		else retorno = (int) (Math.abs(o2.getObjective(0))
//				- Math.abs(o2.getObjective(1)) + Math.abs(o2.getObjective(2)));
		
		return retorno;
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
